<template>
  <div class="user-statistics">
    <el-card class="statistics-card">
      <template #header>
        <div class="card-header">
          <span>统计信息</span>
        </div>
      </template>
      
      <div class="statistics-info">
        <el-row :gutter="20">
          <el-col :span="8">
            <div class="stat-item">
              <div class="label">问卷填写数</div>
              <div class="value">{{ statistics.submissionCount || 0 }}</div>
            </div>
          </el-col>
          <el-col :span="8">
            <div class="stat-item">
              <div class="label">评论数</div>
              <div class="value">{{ statistics.commentCount || 0 }}</div>
            </div>
          </el-col>
          <el-col :span="8">
            <div class="stat-item">
              <div class="label">最近活跃</div>
              <div class="value">{{ formatDate(statistics.lastActiveTime) }}</div>
            </div>
          </el-col>
        </el-row>
      </div>
    </el-card>
  </div>
</template>

<script setup>
import { ref, onMounted } from 'vue'
import request from '@/utils/request'
import { formatDate } from '@/utils'

const statistics = ref({})

const getStatistics = async () => {
  try {
    const res = await request.get('/api/user/statistics')
    statistics.value = res.data
  } catch (error) {
    console.error('获取统计信息失败:', error)
  }
}

onMounted(() => {
  getStatistics()
})
</script>

<style lang="scss" scoped>
.user-statistics {
  padding: 20px;
  
  .statistics-card {
    max-width: 800px;
    margin: 0 auto;
    
    .card-header {
      margin-bottom: 20px;
    }
    
    .statistics-info {
      .stat-item {
        text-align: center;
        padding: 20px;
        background-color: #f5f7fa;
        border-radius: 4px;
        
        .label {
          color: #606266;
          margin-bottom: 10px;
        }
        
        .value {
          color: #303133;
          font-size: 24px;
          font-weight: bold;
        }
      }
    }
  }
}
</style> 